package com.heima.behavior.controller.v1;


import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "app端用户行为处理api",tags = "app端用户行为处理api")
@RestController
@RequestMapping("/api/v1")
public class BehaviorController {

    @Autowired
    ApLikesBehaviorService likesBehaviorService;

    @Autowired
    ApReadBehaviorService readBehaviorService;

    @Autowired
    ApUnlikeBehaviorService unlikeBehaviorService;

    @Autowired
    ApCollectionBehaviorService collectionBehaviorService;

    @Autowired
    ApArticleBehaviorService articleBehaviorService;

    @ApiOperation("点赞/取消点赞行为API")
    @PostMapping("/likes_behavior")
    public ResponseResult likesBehavior(@RequestBody @Validated LikesBehaviorDTO dto){
        return likesBehaviorService.like(dto);
    }

    @ApiOperation("保存阅读行为API")
    @PostMapping("//read_behavior")
    public ResponseResult readBehavior(@RequestBody @Validated ReadBehaviorDTO dto){
        return readBehaviorService.readBehavior(dto);
    }

    @ApiOperation("不喜欢行为API")
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikesBehavior(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return unlikeBehaviorService.unlikeBehavior(dto);
    }

    @ApiOperation("收藏行为API")
    @PostMapping("/collection_behavior")
    public ResponseResult collectBehavior(@RequestBody @Validated CollectionBehaviorDTO dto){
        return collectionBehaviorService.collectBehavior(dto);
    }

    /**
     * 查询文章行为相关信息
     * @param dto
     * @return
     */
    @ApiOperation("文章行为api")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult loadArticleBehavior(@RequestBody @Validated ArticleBehaviorDTO dto){
        return articleBehaviorService.loadArticleBehavior(dto);
    }
}
